import type { RoutingStepModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 获取工艺步骤数据集合
 * @param params 查询参数
 * @returns 返回查询结果
 */
export async function getRoutingStepListApi(params?: any) {
  return requestClient.get<RoutingStepModel[]>(
    '/mes/process/routingStep/list',
    {
      params,
    },
  );
}

/**
 * 分页查询工艺步骤据集合
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getRoutingStepPagedListApi(params?: PageParams) {
  return requestClient.get<PaginationResult<RoutingStepModel>>(
    '/mes/process/routingStep/list-page',
    {
      params,
    },
  );
}

/**
 * 创建工艺步骤
 * @param data 要创建的工艺步骤
 * @returns 返回结果
 */
export async function createRoutingStepApi(data: any) {
  return requestClient.post<boolean>('/mes/process/routingStep', data);
}

/**
 * 更新工艺步骤
 * @param id 工艺步骤 Id
 * @param data 要更新的工艺步骤
 * @returns 返回结果
 */
export async function updateRoutingStepApi(id: number, data: any) {
  return requestClient.put<boolean>(`/mes/process/routingStep/${id}`, data);
}

/**
 * 向上排序工艺步骤
 * @param id 要排序的工艺步骤 Id
 * @returns 返回结果
 */
export async function upSortRoutingStepApi(id: number) {
  return requestClient.put<boolean>(`/mes/process/routingStep/up/${id}`);
}

/**
 * 向下排序工艺步骤
 * @param id 要排序的工艺步骤 Id
 * @returns 返回结果
 */
export async function downSortRoutingStepApi(id: number) {
  return requestClient.put<boolean>(`/mes/process/routingStep/down/${id}`);
}

/**
 * 删除工艺步骤
 * @param id 工艺步骤 Id
 * @returns 返回结果
 */
export async function deleteRoutingStepApi(id: number) {
  return requestClient.delete<boolean>(`/mes/process/routingStep/${id}`);
}
